<template>
	<view class="wrap">
		<view class="setting-group" v-for="(pItem, pIndex) in list" :key="pIndex">
			<uni-list>
				<uni-list-item v-for="(cItem, cIndex) in pItem.children" :key="cIndex" :title="cItem.name"
					:to="cItem.path" showArrow clickable>
				</uni-list-item>
			</uni-list>
		</view>
		<view>
			<button type="warn" @click="logout">安全退出</button>
		</view>
	</view>
</template>

<script>
	const opts = [{
			name: '1',
			children: [{
					path: '/pagesA/ucenter/setting/info/index',
					icon: 'coupon',
					name: '个人信息',
					type: 'page'
				},
				{
					path: '/pagesA/ucenter/setting/info/index',
					icon: 'coupon',
					name: '账户与安全',
					type: 'page'
				}
			]
		},
		{
			name: '2',
			children: [{
					path: '/pagesA/basics/ucenter/help/index',
					icon: 'wxCenter',
					name: '检查更新',
					value: '新版本',
					type: 'button'
				},
				{
					path: '/pagesA/basics/ucenter/help/index',
					icon: 'wxCenter',
					name: '免责申明',
					type: 'page'
				}
			]
		},
		{
			name: '3',
			children: [{
					path: '/pagesA/ucenter/setting/help/index',
					icon: 'wxCenter',
					name: '问题与意见',
					type: 'page'
				},
				{
					path: '/pagesA/ucenter/setting/help/index',
					icon: 'wxCenter',
					name: '帮助与客服',
					type: 'page'
				},
				{
					path: '/pagesA/ucenter/setting/about/index',
					icon: 'citySelect',
					name: '关于我们',
					type: 'page'
				}
			]
		}
	]

	export default {
		data() {
			return {
				pic: 'https://uviewui.com/common/logo.png',
				show: true,
				list: opts
			}
		},
		computed: {
			getIcon() {
				return path => {
					return 'https://cdn.uviewui.com/uview/example/' + path + '.png';
				}
			}
		},
		onLoad() {

		},
		methods: {
			cellClick(type, url) {
				switch (type) {
					case 'button':
						uni.showToast({
							title: '已是最新版本',
							duration: 2000
						});
						break;
					case 'page':
						uni.navigateTo({
							url: url
						})
						break;
					default:
						break;;
				}

			},
			settingClick() {
				uni.navigateTo({
					url: 'setting/index'
				})
			},
			logout() {
				console.log('logout')
				uni.showModal({
					title: '提示',
					content: '确认退出当前账号？',
					success: function(res) {
						if (res.confirm) {
							console.log('用户点击确定');
						}
					}
				});
			}
		}
	}
</script>

<style lang="less" scoped>
	// button {
	// 	margin: 30rpx;
	// }
	.wrap {
		margin-top: 20rpx;

		.setting-group {
			margin-bottom: 20rpx;
		}
	}
</style>
